package com.example.back.common;

import lombok.Data;

@Data
public class Result {
    private String status;
    private Object data;
    private String msg;
    private static final String SUCCESS_STATUS = "200";
    private static final String ERROR_STATUS = "-1";
    private static final String SUCCESS_MSG = "请求成功";
    public static Result success(){
        Result result = new Result();
        result.setStatus(SUCCESS_STATUS);
        result.setMsg(SUCCESS_MSG);
        System.out.println(result);
        return result;
    }
    public static Result success(Object data,String msg) {
        Result result = new Result();
        result.setStatus(SUCCESS_STATUS);
        result.setMsg(msg);
        result.setData(data);
        System.out.println(result);
        return result;
    }
    public static Result error(String msg){
        Result result = new Result();
        result.setStatus(ERROR_STATUS);
        result.setMsg(msg);
        System.out.println(result);
        return result;
    }
    public static Result success(Object data){
        Result result = new Result();
        result.setStatus(SUCCESS_STATUS);
        result.setData(data);
        System.out.println(result);
        return result;
    }
}
